﻿using System.Windows;
using System.Windows.Controls;
using CommomFunctions;

namespace Pilhas
{
    /// <summary>
    /// Interaction logic for Stacks.xaml
    /// </summary>
    public partial class Stacks : Window
    {
        /// <summary>
        /// Variable that contains the information about the controls and their operations.
        /// </summary>
        ControlVariables ctrls = new ControlVariables();
        
        /// <summary>
        /// Constructor that executes the default initialization and then creates the other necessary controls 
        /// </summary>
        public Stacks()
        {
            InitializeComponent();
            createStack();
        }

        /// <summary>
        /// Creates the stack. 
        /// The array "btns" contains all the buttons in the project. It will be used to control
        /// which button is enabled or disabled according to the operation that is being executed.
        /// </summary>
        public void createStack()
        {
            Button[] btns = { btnCreate, btnDestroy, btnPop, btnPush };
            ctrls.btnsToEnableDisable(btns);
            ctrls.addOtherControls(myGrid);
        }

        private void grid_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            ctrls.gridSizeChanged();
        }

        #region Buttons click events controls
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.Create, stackBorder);
        }

        private void btnDestroy_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.Destroy, stackBorder);
        }

        private void btnPop_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.Pop);
        }

        public void btnPush_Click(object sender, RoutedEventArgs e)
        {
            ctrls.buttonClicked(ButtonClicked.Push);
        } 
        #endregion

        #region Menu click events controls
        private void useLetters_Click(object sender, RoutedEventArgs e)
        {
            ctrls.useLettersClicked(useLetters, stackBorder);
        }

        private void help_Click(object sender, RoutedEventArgs e)
        {
            Ajuda.openHelp();
        }

        private void about_Click(object sender, RoutedEventArgs e)
        {
            Ajuda.openAbout();
        }

        private void tutorial_Click(object sender, RoutedEventArgs e)
        {
            Ajuda.openTutorial("Pilha.wmv");
        }         
        #endregion
    }
}
